<?php
/**
 * Created by PhpStorm.
 * User: Yooke
 * Date: 2016/5/13
 * Time: 16:47
 */
namespace App\Http\Controllers\Mobile;

use App\Interfaces\ActivityService;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Activity;
use Auth;

class ActivityController extends Controller
{

    public function index(Request $request,$id)
    {
        $activity = Activity::find($id);
        if(!$activity){
            return null;
        }
        $user=Auth::user();
        return view('mobile.activity.index',compact(['id','user','activity']));

    }
    public function detail(Request $request,$id,ActivityService $activityService){
        $activity_cat_id= $request->get('activity_cat_id');
        $fristActivityGoods = $activityService->getActivityCat($id)->first();
        return view('mobile.activity.detail',compact('id','fristActivityGoods','activity_cat_id'));
    }

    public function getActivityGoods(Request $request,ActivityService $activityService){
        $activity_cat_id = $request->get('activity_cat_id');
        //dd($activity_cat_id);
        $page = $request->get('page');
        $activityGoods = $activityService->getMobileActivityGoods($activity_cat_id,$page);
        $goods = $activityGoods->toArray();
        return response()->json(['goods'=>$goods,'status'=>1]);

    }


}